﻿@{
    ViewBag.Title = "公告管理";
    Layout = "~/Views/Shared/_Form.cshtml";
}
<link href="~/Content/scripts/plugins/simditor/css/simditor.css" rel="stylesheet" />
<script src="~/Content/scripts/plugins/simditor/js/module.min.js"></script>
<script src="~/Content/scripts/plugins/simditor/js/uploader.min.js"></script>
<script src="~/Content/scripts/plugins/simditor/js/hotkeys.min.js"></script>
<script src="~/Content/scripts/plugins/simditor/js/simditor.min.js"></script>
<link href="~/Content/scripts/plugins/cxColor/css/jquery.cxcolor.css" rel="stylesheet" />
<script src="~/Content/scripts/plugins/cxColor/js/jquery.cxcolor.js"></script>
<script>
    var keyValue = request('keyValue');
    var editor = null;
    $(function () {
        editor = new Simditor({
            textarea: $('#F_NewsContent'),
            placeholder: '这里输入公告内容...',
            toolbar: ['title', 'bold', 'italic', 'underline', 'strikethrough', 'color', '|', 'ol', 'ul', 'blockquote', 'code', 'table', '|', 'link', 'image', 'hr', '|', 'indent', 'outdent']
        });
        initControl();
    })
    //初始化控件
    function initControl() {
        //公告类别
        $("#F_Category").ComboBox({
            param: { EnCode: "NoticeCategory" },
            url: "../../SystemManage/DataItemDetail/GetDataItemListJson",
            description: "==请选择==",
            id: "F_ItemValue",
            text: "F_ItemName",
            height: "230px"
        });
        //获取表单
        if (!!keyValue) {
            $.SetForm({
                url: "../../PublicInfoManage/Notice/GetFormJson",
                param: { keyValue: keyValue },
                success: function (data) {
                    $("#form1").SetWebControls(data);
                    editor.setValue(data.F_NewsContent);
                    $("#F_FullHead").attr("color", data.FullHeadColor).css("color", data.FullHeadColor);
                }
            });
        }
    }
    //选择颜色-设置标题色彩
    function SelectColorEvent() {
        var mycolor = $("#select_color").cxColor();
        mycolor.show();
        $("#select_color").bind("change", function () {
            $("#F_FullHead").css("color", this.value).attr("color", this.value);
        });
    }
    //保存表单
    function AcceptClick() {
        if (!$('#form1').Validform()) {
            return false;
        }
        var postData = {
            F_FullHead: $("#F_FullHead").val(),
            F_FullHeadColor: $('#F_FullHead').attr('color'),
            F_Category: $("#F_Category").attr('data-value'),
            F_ReleaseTime: $("#F_ReleaseTime").val(),
            F_NewsContent: editor.getValue()
        }
        $.SaveForm({
            url: "../../PublicInfoManage/Notice/SaveForm?keyValue=" + keyValue,
            param: postData,
            loading: "正在保存数据...",
            success: function () {
                $.currentIframe().$("#gridTable").trigger("reloadGrid");
            }
        })
    }
</script>
<div style="margin-top: 20px; margin-right: 30px;">
    <table class="form" style="table-layout: auto;">
        <tr>
            <td class="formTitle">公告标题<font face="宋体">*</font></td>
            <td class="formValue" colspan="3">
                <input id="F_FullHead" type="text" class="form-control" style="color: #000000;" placeholder="请输入标题" isvalid="yes" checkexpession="NotNull" />
                <span id="select_color" class="input-button" style="width: 18px; margin-top: -9px; height: auto;" title="使用彩色标题" onclick="SelectColorEvent()">
                    <img src="~/Content/images/large_tiles.png" /></span>
            </td>
        </tr>
        <tr>
            <td class="formTitle">公告类别<font face="宋体">*</font></td>
            <td class="formValue">
                <div id="F_Category" type="select" class="ui-select" isvalid="yes" checkexpession="NotNull"></div>
            </td>
            <td class="formTitle">发布时间</td>
            <td class="formValue">
                <input id="F_ReleaseTime" readonly type="text" class="form-control" value="@LeaRun.Util.Time.GetToday("yyyy/MM/dd HH:mm")" />
            </td>
        </tr>
        <tr>
            <td class="formTitle">信息来源</td>
            <td class="formValue">
                <input id="F_SourceName" type="text" class="form-control" />
            </td>
            <td class="formTitle">来源地址</td>
            <td class="formValue">
                <input id="F_SourceAddress" type="text" class="form-control" />
            </td>
        </tr>
        <tr>
            <th class="formTitle" valign="top" style="padding-top: 4px;">公告内容</th>
            <td class="formValue" colspan="3">
                <textarea id="F_NewsContent" class="form-control" rows="5"></textarea>
            </td>
        </tr>
    </table>
</div>
